import Vue from 'vue'
import VueRouter from 'vue-router'
import Recommend from '@/views/Home/Recommend'
import Classify from '@/views/Home/Classify'
import MiMoments from '@/views/Home/MiMoments'
import ShopCar from '@/views/Home/ShopCar'
import Center from '@/views/Home/Center'
// 推荐的子级路由
import Home from '@/views/Home/Home'
import Smart from '@/views/Home/Recommend/Smart'
import TV from '@/views/Home/Recommend/TV'
import HomeAppliances from '@/views/Home/Recommend/HomeAppliances'
import Notebook from '@/views/Home/Recommend/Notebook'
import Search from '@/views/Home/Recommend/Search'
Vue.use(VueRouter)

const routes = [
  {
    path: '/Recommend',
    component: Recommend,
    children: [
      {
        path: '/Recommend/Home',
        component: Home,
        meta: {
          keepAlive: true
        }
      },
      {
        path: '/Recommend/Smart',
        component: Smart,
        meta: {
          keepAlive: true
        }
      },
      {
        path: '/Recommend/TV',
        component: TV,
        meta: {
          keepAlive: true
        }
      },
      {
        path: '/Recommend/HomeAppliances',
        component: HomeAppliances,
        meta: {
          keepAlive: true
        }
      },
      {
        path: '/Recommend/Notebook',
        component: Notebook,
        meta: {
          keepAlive: true
        }
      },
      {
        path: '/Recommend/Search',
        component: Search,
        meta: {
          keepAlive: true
        }
      },
      {
        path: '/Recommend',
        redirect: '/Recommend/Home'
      }
    ]
  },
  {
    name: 'Classify',
    path: '/Classify/:height',
    component: Classify,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/MiMoments',
    component: MiMoments,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/ShopCar',
    component: ShopCar,
    meta: {
      keepAlive: false
    }
  },
  {
    path: '/Center',
    component: Center,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '*',
    redirect: '/Recommend'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
